
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>icf</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/public/layui/admin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/public/layui/admin/style/admin.css" media="all">
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-header">CardTenantRel</div>
      <div class="layui-card-body" style="padding: 15px;">
        <form class="layui-form" action="" lay-filter="component-form-group">
          {% if data.detail.Id %}
            <input name="id" type="hidden" value="{{ data.detail.Id }}"/>
          {% endif %}

		<!-- 
<div class="layui-form-item">
  <label class="layui-form-label">id</label>
  <div class="layui-input-block">
    <input type="text" 
           id="id" 
           name="id" 
           value="{{ data.detail.Id }}"
           lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
  </div>
</div>
-->
<!-- 
<div class="layui-form-item">
  <label class="layui-form-label">deleted</label>
  <div class="layui-input-block">
    <input type="text" 
           id="if_del" 
           name="if_del" 
           value="{{ data.detail.IfDel }}"
           lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
  </div>
</div>
-->

<div class="layui-form-item">
  <label class="layui-form-label">create</label>
  <div class="layui-input-block">
    <input type="text" 
           id="cdate" 
           name="cdate" 
           value="{{ data.detail.Cdate }}"
           lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
  </div>
</div>


<div class="layui-form-item">
  <label class="layui-form-label">update</label>
  <div class="layui-input-block">
    <input type="text" 
           id="udate" 
           name="udate" 
           value="{{ data.detail.Udate }}"
           lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
  </div>
</div>


<div class="layui-form-item">
  <label class="layui-form-label">卡ID</label>
  <div class="layui-input-block">
    <input type="text" 
           id="card_id" 
           name="card_id" 
           value="{{ data.detail.CardId }}"
           lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
  </div>
</div>


<div class="layui-form-item">
  <label class="layui-form-label">小程序app id</label>
  <div class="layui-input-block">
    <input type="text" 
           id="weapp_id" 
           name="weapp_id" 
           value="{{ data.detail.WeappId }}"
           lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
  </div>
</div>


<div class="layui-form-item">
  <label class="layui-form-label">common</label>
  <div class="layui-input-block">
    <input type="text" 
           id="common" 
           name="common" 
           value="{{ data.detail.common }}"
           lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
  </div>
</div>



          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <button class="layui-btn" lay-submit="" lay-filter="edit-submit">提交</button>
                <a href="javascript:goBack()" class="layui-btn layui-btn-primary">返回</a>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>

    
  <script src="/public/layui/admin/layui/layui.js"></script>
  <script>
      layui.config({
        base: '/public/layui/admin/' //静态资源所在路径
      }).extend({
        index: 'lib/index' //主入口模块
      }).use(['index', 'form', 'laydate','jquery','upload'], function(){
        var $ = layui.$
        ,admin = layui.admin
        ,element = layui.element
        ,layer = layui.layer
        ,laydate = layui.laydate
        ,form = layui.form;
        
        form.render(null, 'component-form-group');
        laydate.render({
          elem: '#LAY-component-form-group-date'
        });
        
        /* 自定义验证规则 */
        form.verify({
          title: function(value){
            if(value.length < 0){
              return '请输入';
            }
          }
          ,pass: [/(.+){6,12}$/, '密码必须6到12位']
          ,content: function(value){
            layedit.sync(editIndex);
          }
        });

        // 文件上传
        var upload = layui.upload;
        upload.render({
            elem: '#upload-drag',
            url: '/admin/upload',
            done: function(res) {
                console.log(res)
                $("#img-upload").attr("src", res.data.imgurl);
                // TODO: $("#prdminipic").val(res.data.imgurl);
            }
        });
        
        /* 监听提交 */
        form.on('submit(edit-submit)', function(data){
          // parent.layer.alert(JSON.stringify(data.field), {
          //   title: '最终的提交信息'
          // })
          $.ajax({
            type: "POST",
            url : "/admin/CardTenantRel/editpage",
            data: data.field,
            async: true,
            error: function(request) {
              parent.layer.alert(JSON.stringify(request), {title: '操作失败'});
            },
            success: function(response) {
              console.log(response);
              var rt = JSON.parse(response);
              if(rt.code == 0){
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
              }else{
                parent.layer.alert(rt.msg, {title: '操作失败'});
              }
            }
          });
          return false;
        });

        /* 监听指定开关 
        form.on('switch(component-form-switchTest)', function(data){
          layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
            offset: '6px'
          });
          layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });*/
      });
      
      // 页面返回上一页面
      function goBack(){
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.layer.close(index);
      };

  </script>
</body>
</html>
